home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 June: Reference Library / Dev.CD Jun 95 / Dev.CD Jun 95.toast / What's New? / Sample Code / QuickTime Sample Code / DTS QT Utilities.Apr-95 / Projects & Test Apps / QT Internals / QTInternals.c < prev    next >
Encoding:
Text File  |  1995-04-16  |  9.1 KB  |  281 lines  |  [TEXT/MPCC]

  1. /*
  2.     File:        QTInternals.c
  3.  
  4.     Contains:    Functions dealing with dumping internal movie information.
  5.  
  6.     Written by:    DTS
  7.  
  8.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.        <1>         1/4/95    khs        first file
  13.        
  14. */
  15.  
  16.  
  17. // INCLUDES
  18. #include "QTInternals.h"
  19. #include "DTSQTUtilities.h"
  20.  
  21.  
  22. // ______________________________________________________________________
  23. // FUNCTIONS
  24.  
  25. // ______________________________________________________________________
  26. void ShowMovieTrackInfo(Movie theMovie)
  27. {
  28.     long                        aTrackCount, index;
  29.     Track                    aTrack;
  30.     long                        aTrackUsage;
  31.     OSErr                    anErr  = noErr;
  32.     Str255                    tmpStr;
  33.     Fixed                    height, width;
  34.     short                    trackVol;
  35.     MatrixRecord        mr;
  36.     
  37.     
  38.     GetWTitle(FrontWindow(), tmpStr);
  39.     printf("\nTrack Information for %s:\n", p2cstr(tmpStr));
  40.     
  41.     // TRACK COUNT
  42.     aTrackCount = GetMovieTrackCount(theMovie);
  43.     anErr = GetMoviesError(); DebugAssert(anErr == noErr);
  44.     if(anErr != noErr) return;
  45.     
  46.     if(aTrackCount == 0) 
  47.     {
  48.         printf("The Movie has no tracks.\n");
  49.         return;
  50.     }
  51.     else
  52.         printf("The Movie has %d tracks.\n", aTrackCount);
  53.  
  54.     // Parse through each track and get more information:
  55.     for(index = 1; index <= aTrackCount; index++)
  56.     {
  57.         OSType aTrackType;
  58.         Media aMedia;
  59.         
  60.         printf("\n");
  61.         
  62.         aTrack = GetMovieIndTrack(theMovie, index);
  63.         
  64.         // TRACK TYPE
  65.         aMedia = GetTrackMedia(aTrack);
  66.         GetMediaHandlerDescription(aMedia, &aTrackType, 0, 0);
  67.         
  68.         switch (aTrackType)
  69.         {
  70.             case SoundMediaType: printf("This is a sound track.\n"); break;
  71.             case VideoMediaType: printf("This is a video track.\n"); break;
  72.             case TextMediaType: printf("This is a text track.\n"); break;
  73.             case MPEGMediaType: printf("This is an MPEG track.\n"); break;
  74.             case MusicMediaType: printf("This is a music track.\n"); break;
  75.             case TimeCodeMediaType: printf("This is a time code track.\n"); break;
  76.             default: 
  77.             {
  78.                 Byte *bp = (Byte *)&aTrackType;
  79.                 printf("The track is of type '%c%c%c%c' format.\n", bp[0], bp[1], bp[2], bp[3]);
  80.                 break;
  81.             }
  82.         }
  83.         
  84.         // TRACK ID
  85.         printf("Track ID: %d\n", GetTrackID(aTrack));
  86.     
  87.         // TRACK ENABLED
  88.         if(GetTrackEnabled(aTrack))
  89.             printf("Track is enabled.\n");
  90.         else
  91.             printf("Track is disabled.\n");
  92.         
  93.         // TRACK LAYER
  94.         printf("Track Layer: %d\n", GetTrackLayer(aTrack));
  95.         
  96.         // TRACK USAGE
  97.         aTrackUsage = GetTrackUsage(aTrack);
  98.         if(aTrackUsage & trackUsageInMovie)
  99.             printf("Track is used in Movie.\n");
  100.         if(aTrackUsage & trackUsageInPreview)
  101.             printf("Track is used in a preview.\n");
  102.         if(aTrackUsage & trackUsageInPoster)
  103.             printf("Track is used in a poster.\n");
  104.     
  105.         // TRACK DURATION
  106.         printf("Duration of the track = %ld\n", GetTrackDuration(aTrack));
  107.         
  108.         // TRACK DIMENSIONS
  109.         GetTrackDimensions(aTrack, &width, &height);
  110.         printf("Track width = %ld, Track height = %ld\n", Fix2Long(width), Fix2Long(height));
  111.         
  112.         // TRACK MATRIX
  113.         GetTrackMatrix(aTrack, &mr);
  114.         
  115.         printf("Matrix record, row 0 = [%ld], [%ld], [%ld]\n", Fix2Long(*mr.matrix[0,0]), 
  116.                                 Fix2Long(*mr.matrix[0,1]), Fix2Long(*mr.matrix[0,2]));
  117.         printf("Matrix record, row 1 = [%ld], [%ld], [%ld]\n", Fix2Long(*mr.matrix[1,0]), 
  118.                                 Fix2Long(*mr.matrix[1,1]), Fix2Long(*mr.matrix[1,2]));
  119.         printf("Matrix record, row 2 = [%ld], [%ld], [%ld]\n", Fix2Long(*mr.matrix[2,0]), 
  120.                                 Fix2Long(*mr.matrix[2,1]), Fix2Long(*mr.matrix[2,2]));
  121.         
  122.         // TRACK VOLUME
  123.         trackVol = GetTrackVolume(aTrack);
  124.         if(trackVol == 255)
  125.             printf("Track Volume is 1.0\n");
  126.         else
  127.             printf("Track Volume = %d.%d\n", (signed short)(trackVol >> 8) , (trackVol & 0xFF));
  128.     }
  129. }
  130.  
  131.  
  132. // ______________________________________________________________________
  133. void ShowMovieVideoInfo(Movie theMovie)
  134. {
  135.     Str255     tmpStr;
  136.     short        trackCount, index;
  137.     OSErr        anErr = noErr;
  138.     
  139.     DebugAssert(aMovie != NULL);
  140.     
  141.     GetWTitle(FrontWindow(), tmpStr);
  142.     printf("\nVideo Media Information for %s:\n", p2cstr(tmpStr));
  143.  
  144.     // VIDEO FRAMES/SAMPLES
  145.     printf("The movie has %d video frames (samples)\n", QTUCountMediaSamples(theMovie, VideoMediaType));
  146.  
  147.     printf("The duration of the first video sample is %ld\n", QTUGetDurationOfFirstMovieSample(theMovie, VideoMediaType));
  148.     
  149.     // Get the Image Description Structure and present the values.
  150.     trackCount = GetMovieTrackCount(theMovie);
  151.     
  152.     for(index = 1; index <= trackCount; index++)
  153.     {
  154.         Track        aTrack = NULL;
  155.         Media        aMedia = NULL;
  156.         OSType        aMediaType;
  157.         
  158.         aTrack = GetMovieIndTrack(theMovie, index); DebugAssert(aTrack != NULL);
  159.         aMedia = GetTrackMedia(aTrack); DebugAssert(aMedia != NULL);
  160.         anErr = GetMoviesError(); DebugAssert(anErr == noErr);
  161.         if(anErr != noErr)
  162.         {
  163.             printf("Problems with getting trackmedia = %d\n", anErr);
  164.             return;
  165.         }
  166.  
  167.         GetMediaHandlerDescription(aMedia, &aMediaType, 0, 0);
  168.         if(aMediaType == VideoMediaType) // We just want to check the video media samples.
  169.         {
  170.             SampleDescriptionHandle anImageDesc = NULL;
  171.             anImageDesc = (SampleDescriptionHandle)NewHandle(sizeof(SampleDescription));
  172.             DebugAssert(GetMemErr == noErr);
  173.  
  174.             GetMediaSampleDescription(aMedia, 1, anImageDesc);
  175.             anErr = GetMoviesError(); DebugAssert(anErr == noErr);
  176.             MoveHHi((Handle)anImageDesc); HLock((Handle)anImageDesc); // Really would not need to, but printf (don't trust that one
  177.                                                                                                           // due to the MetroWerks Sioux environment).
  178.             if(anErr != noErr)
  179.             {
  180.                 DisposeHandle((Handle)anImageDesc);
  181.                 continue;
  182.             }
  183.  
  184.             // OK, we have the Image Description, now present the values (see IM:QuickTime, page 3-50 for more
  185.             // information about the ImageDescription structure).
  186.             
  187.             printf("The video track has a pixel depth of %d.\n", (*(ImageDescriptionHandle)anImageDesc)->depth);
  188.     
  189.             printf("The video track has a source image width of %d.\n", (*(ImageDescriptionHandle)anImageDesc)->width);
  190.             printf("The video track has a source image height of %d.\n", (*(ImageDescriptionHandle)anImageDesc)->height);
  191.             printf("The video track has a horizontal resolution of %ld.\n", Fix2Long( (*(ImageDescriptionHandle)anImageDesc)->hRes) );
  192.             printf("The video track has a vertical resolution of %ld.\n", Fix2Long( (*(ImageDescriptionHandle)anImageDesc)->vRes) );
  193.             
  194.             printf("The codec used to compress the video samples:  %s\n", p2cstr( (*(ImageDescriptionHandle)anImageDesc)->name) );
  195.             printf("Note that this is the codec for the first video sample, the video samples in the movie might have various codecs used...\n");
  196.             {
  197.                 Byte *bp = (Byte *)&(*(ImageDescriptionHandle)anImageDesc)->vendor;
  198.                 printf("The video track was compressed by codec provided by '%c%c%c%c'.\n", bp[0], bp[1], bp[2], bp[3]);
  199.             }
  200.             printf("The temporal compression setting is %ld\n",  (*(ImageDescriptionHandle)anImageDesc)->temporalQuality);
  201.             printf("The spatial compression setting is %ld\n",  (*(ImageDescriptionHandle)anImageDesc)->spatialQuality);
  202.             
  203.             
  204.             printf("The image description structure is %ld bytes in size.\n", 
  205.                             (*(ImageDescriptionHandle)anImageDesc)->idSize);
  206.  
  207.             DisposeHandle((Handle)anImageDesc);
  208.         }
  209.     }
  210. }
  211.  
  212.  
  213. // ______________________________________________________________________
  214. void ShowMovieSoundInfo(Movie theMovie)
  215. {
  216.     Str255     tmpStr;
  217.     short        trackCount, index;
  218.     OSErr        anErr = noErr;
  219.     
  220.     DebugAssert(aMovie != NULL);
  221.     
  222.     GetWTitle(FrontWindow(), tmpStr);
  223.     printf("\nSound Media Information for %s:\n", p2cstr(tmpStr));
  224.     
  225. #ifdef THIS_WILL_TAKE_LONG
  226.     printf("The movie has %d sound samples (samples)\n", QTUCountMediaSamples(theMovie, SoundMediaType));
  227. #endif // THIS_WILL_TAKE_LONG
  228.  
  229.     // Get the sound description handle and munch it:
  230.     trackCount = GetMovieTrackCount(theMovie);
  231.     
  232.     for(index = 1; index <= trackCount; index++)
  233.     {
  234.         Track        aTrack = NULL;
  235.         Media        aMedia = NULL;
  236.         OSType    aMediaType;
  237.         
  238.         aTrack = GetMovieIndTrack(theMovie, index); DebugAssert(aTrack != NULL);
  239.         aMedia = GetTrackMedia(aTrack); DebugAssert(aMedia != NULL);
  240.         anErr = GetMoviesError(); DebugAssert(anErr == noErr);
  241.         if(anErr != noErr)
  242.         {
  243.             printf("Problems with getting trackmedia = %d\n", anErr);
  244.             return;
  245.         }
  246.         
  247.         GetMediaHandlerDescription(aMedia, &aMediaType, 0, 0);
  248.         if(aMediaType == SoundMediaType)        // We just want to check out the sound description handles.
  249.         {
  250.             SampleDescriptionHandle aDesc = NULL;
  251.             aDesc = (SampleDescriptionHandle)NewHandle(sizeof(SampleDescription)); 
  252.             DebugAssert(GetMemErr() == noErr);
  253.         
  254.             GetMediaSampleDescription(aMedia, 1, aDesc);
  255.             anErr = GetMoviesError(); DebugAssert(anErr == noErr);
  256.             MoveHHi((Handle)aDesc); HLock((Handle)aDesc); // Really would not need to, but printf (don't trust that one
  257.                                                                                      // due to the MetroWerks Sioux environment).
  258.             if(anErr != noErr)
  259.             {
  260.                 DisposeHandle((Handle)aDesc);
  261.                 continue;
  262.             }
  263.             // OK, we have the sound description handle now, present the values
  264.             printf("The sound track rate is %d Hz.\n", (*(SoundDescriptionHandle)aDesc)->sampleRate >> 16);
  265.             
  266.             printf("The sound track size is %d bit.\n", (*(SoundDescriptionHandle)aDesc)->sampleSize);
  267.             
  268.             printf("The sound track has %d channel(s).\n", (*(SoundDescriptionHandle)aDesc)->numChannels);
  269.             {
  270.                 Byte *bp = (Byte *)&(*(SoundDescriptionHandle)aDesc)->dataFormat;
  271.                 printf("The sound track has the '%c%c%c%c' format.\n", bp[0], bp[1], bp[2], bp[3]);
  272.             }
  273.             
  274.             printf("The sound description structure is %ld bytes in size.\n", 
  275.                             (*(SoundDescriptionHandle)aDesc)->descSize);
  276.         
  277.         }
  278.     }
  279. }
  280.  
  281.